package my.learn.server.lazy.netty.tcp.advanced;

import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Role;
import org.springframework.stereotype.Component;
import my.learn.common.NettyCommunicationIdContext;
import my.learn.common.NettyProxyMsg;
import my.learn.common.NettyRealIdContext;
import my.learn.common.advanced.tcp.server.AbstractHandleTcpReportClientTransferClientPermeateChannelInitSuccessfulTypeAdvanced;
import my.learn.common.advanced.tcp.server.AbstractHandleTcpReportClientTransferClientTypeAdvanced;
import my.learn.common.advanced.tcp.server.AbstractHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced;
import my.learn.common.constant.TcpMessageType;
import my.learn.common.enums.ChannelFlowEnum;
import my.learn.common.other.SpringContextHolder;
import my.learn.common.utils.ChannelAttributeKeyUtils;
import my.learn.server.lazy.netty.tcp.socket.NettyTcpClientPermeateServerConnectRealSocket;

/**
 * 服务端处理客户端 关闭一个访客
 */
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Slf4j
@Component
public class ServerHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced extends AbstractHandleTcpReportServicePermeateClientCloseVisitorTypeAdvanced<NettyProxyMsg> {


    /**
     * 处理当前数据
     *
     * @param channel       当前通道
     * @param nettyProxyMsg 通道数据
     */
    @Override
    protected void doHandler(Channel channel, NettyProxyMsg nettyProxyMsg) {
        // 关闭访客通道
        byte[] visitorId = nettyProxyMsg.getVisitorId();
        NettyCommunicationIdContext.clear(visitorId);
        NettyRealIdContext.clear(visitorId);
    }
}
